<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>去掉重复的字符</title>
</head>
<body>
    <!--  aabccd，去掉重复的字符，使结果显示 abcd -->
    <script>
         var str = 'aabccd';
        var obj = {};
        for (var i = 0; i < str.length; i++) {
            obj[str[i]] = 1;
        }
        var str1 = '';
        for (var key in obj) {
            str1 += key;
        }
        console.log(str1);
    </script>
    
</body>
</html>